Repository navigation
test(e2e): Add a cloudflare-pi-durable end-to-end application - #25022
Conversation
size-limit report 📦
|
259167d to
e5c842b
Compare
8bfd4a7 to
a095187
Compare
a095187 to
ae5a2f8
Compare
ae5a2f8 to
bf50db6
Compare
bf50db6 to
0059f6c
Compare
c57d751 to
0059f6c
Compare
a528063 to
264b42d
Compare
andreiborza
left a comment
There was a problem hiding this comment.
Could we maybe also send the data to sentry and assert on it to make it truly e2e?
| @@ -0,0 +1,133 @@ | |||
| import { expect, test } from '@playwright/test'; | |||
There was a problem hiding this comment.
l: Let's use constants from sentry conventions as much as possible.
264b42d to
80d2a2d
Compare
80d2a2d to
80540af
Compare
| this.ctx.abort('crash_once resets the Durable Object'); | ||
| throw new Error('The Durable Object did not reset'); |
There was a problem hiding this comment.
Bug: The crash_once function unconditionally throws an error after calling ctx.abort(). Since abort() doesn't halt execution, the tool will always fail instead of being reset and replayed.
Severity: MEDIUM
Suggested Fix
Remove the throw new Error('The Durable Object did not reset'); line. The ctx.abort() call is sufficient to trigger the reset, and the subsequent throw prevents the intended replay mechanism from working correctly. The code should simply call this.ctx.abort(...) and then exit the function.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location:
dev-packages/e2e-tests/test-applications/cloudflare-pi-durable/src/assistant.ts#L75-L76
Potential issue: In the `crash_once` tool, `this.ctx.abort()` is called to schedule a
reset of the Durable Object. However, `ctx.abort()` does not halt synchronous execution,
so the subsequent `throw new Error(...)` is always executed on the first invocation.
This causes the tool's `execute` function to fail with an exception, which is contrary
to the intended "replay-safe" behavior described in the code comments and expected by
the tests. The Node.js equivalent uses `process.exit()`, which correctly terminates the
process. This implementation will likely cause the tool to be marked as failed instead
of being replayed after the reset.
Also affects:
dev-packages/e2e-tests/test-applications/cloudflare-pi-durable/tests/pi-durable.test.ts:100~103
Did we get this right? 👍 / 👎 to inform future reviews.
80540af to
a3e202a
Compare
a3e202a to
d1084df
Compare
Going to answer as here: #24994 (comment) |
Runs pi-durable in a Durable Object through the PiHarness of the Cloudflare Agents SDK, with @sentry/cloudflare/vite as the only Sentry setup. The tests check the run trace with its chat, execute_tool and provider spans, a throwing tool, and a run that resumes in a new trace after the Durable Object resets during a tool call. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
d1084df to
c49ea1b
Compare
Cloudflare now hosts pi-durable in Durable Objects through the Agents SDK
PiHarness(changelog). This app runs pi-durable that way, with@sentry/cloudflare/viteas the only Sentry setup. It checks that a prompt becomes aninvoke_agenttrace withchat,execute_tooland providerhttp.clientspans, that a throwing tool is reported on its span, and that a run resumes in a new trace after the Durable Object resets during a tool call. The reset usesctx.abort(), which drops the object like an eviction; the next request starts it again, andPiHarnessresumes pi from its SQLite state.Like
node-pi-durableandcloudflare-think, it calls a real model through OpenRouter, so it is optional. The changelog example uses Workers AI (createAI({ binding: env.AI })), but the AI binding needs a Cloudflare account even in local dev, so that path has a unit test in #24993 instead.This app found a bug that #24993 now fixes:
@sentry/cloudflareinitializes the SDK inside each request, so the client is on the scope of that request only. The task phases ran on a copy of the default scope, had no client, and dropped every pi-durable span and error.🤖 Generated with Claude Code